package com.fanghuaman.product.controller;


import com.fanghuaman.model.common.vo.ResponseResult;
import com.fanghuaman.model.product.dto.ProductPageDto;
import com.fanghuaman.model.product.pojo.Product;
import com.fanghuaman.product.service.ProductService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 * 前端控制器
 * </p>
 *
 * @author smh
 * @since 2024-12-08
 */
@RestController
@RequestMapping("/public")
public class ProductController {

    @Autowired
    private ProductService productService;

    /**
     * 分页查询商品
     *
     * @param productPageDto
     * @return
     */
    @PostMapping("/list")
    public ResponseResult list(@RequestBody ProductPageDto productPageDto) {
        ResponseResult result = productService.list(productPageDto);
        return result;
    }

    @GetMapping("/get/{id}")
    public ResponseResult get(@PathVariable("id") Long id) {
        Product product = productService.getById(id);
        return ResponseResult.success(product);
    }

}

